{if condition="$attachlink neq ''"}


<div class="article-down">
    <?php $cnf=$attachlinkConfig;?>
    <div class="title">下载地址<span style="font-size: 16px"> ({if $cnf.download_type eq 1}评论后方可下载{elseif $cnf.download_type eq 2 && $attachlink.score>0}￥{$attachlink.score}金币{else /}免费{/if})</span>
    </div>
    <ul>
        {volist name="attachlink.urls" id="link"}
        <li><a href="javascript:;" data-linkid="{$attachlink.link_key}-{$key}"
               class="downbtn normal" target="_blank" data-passwd="{$link.passwd|default=''}" data-code="{$link.code|default=''}"
               rel="nofollow"><i class="fa fa-download"></i>{$link.title}</a></li>
        {/volist}
    </ul>
</div>

<script>

    $('.downbtn').on('click', function () {
        var obj = $(this);
        var code = obj.data('code');
        var passwd = obj.data('passwd');
        var linkid = obj.data('linkid');
        var html = '';
        if (code || passwd) {
            if (code) {
                html += '提取码是：' + code + '<br/>';
            }
            if (passwd) {
                html += '解压码是：' + passwd + '<br/>';
            }
        }
        $.post("{:addons_url('attachlink://Index/download',array(),true)}", {linkid: linkid}, function (res) {
            if (res.code == 1) {
                if (html) {
                    layer.open({
                        title: '下载提示',
                        content: html,
                        end: function () {
                            layer.msg(res.msg, function(){
                                window.open(res.data.url);
                            });
                        }
                    });
                } else {
                    layer.msg(res.msg, function(){
                        window.open(res.data.url);
                    });
                }

            } else {
                layer.msg(res.msg, {
                    icon: 2,
                    anim: 6,
                    time: 1000
                });
            }
        });
        return false;
    });
</script>
{/if}